package com.itheima.sh.config;

import com.itheima.sh.intercepter.MyInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description:
 * @Version: V1.0
 */
@Configuration   // 配置类： 替代 xml 配置文件
public class WebMvcConfig implements WebMvcConfigurer {

    /**
     * 添加 拦截器
     * @param registry
     * 拦截方式： /**
     * 静态资源放行：
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyInterceptor())
                .addPathPatterns("/**")   // 拦截器请求
                .excludePathPatterns("/js/**","/image/**","/css/**");  // 放行
    }


}
